public class HTMLTeamFormatter implements TeamFormatter{
    private static volatile HTMLTeamFormatter singletonInstance = null;

    private HTMLTeamFormatter(){

    }

    public static synchronized HTMLTeamFormatter getSingletonInstance() {
        if(singletonInstance == null){
            singletonInstance = new HTMLTeamFormatter();
        }
        return singletonInstance;
    }


    @Override
    public String formatTeam(Team team) {

        StringBuilder sb = new StringBuilder();

        sb.append("<html>" + "\n").
                append("\t<body>" + "\n").
                append("\t\t<center>" + "<h2>Team Information</h2>" + "</center>" + "\n").
                append("\t\t" + team.getTeamId() + " " + team.getTeamName() + " " + team.getDepartment() + "<br>" + "\n").
                append("\t\tcreator[" + team.getCreator().getId() + " " + team.getCreator().getName() + " " + team.getCreator().getPhoneNo() + " " + team.getCreator().getEmail() + " " + team.getCreator().getStudentNo());
        if(team.getCreator().getGender()){
            sb.append(" " + "女");
        }else{
            sb.append(" " + "男");
        }
        sb.append(" " + team.getCreator().getDepartment()).
            append("]" + "<br>" + "\n");
        sb.append("\t\t<h3>" + "StudentList" + "</h3>" + "\n").
                append("\t\t<blockquote>" + "\n");
        for (Student student:team.getStudentList()) {
            sb.append("\t\t\t" + student.getId() + " " + student.getName() + " " + student.getPhoneNo() + " " + student.getEmail() + " " + student.getStudentNo());
            if(student.getGender()){
                sb.append(" " + "女");
            }else{
                sb.append(" " + "男");
            }
            sb.append(" " + student.getDepartment()).
                    append("<br>" + "\n");
        }
        sb.append("\t\t</blockquote>" + "\n");

        sb.append("\t\t<h3>" + "TeacherList" + "</h3>" + "\n").
                append("\t\t<blockquote>" + "\n");
        for (Teacher teacher:team.getTeacherList()) {
            sb.append("\t\t\t" + teacher.getId() + " " + teacher.getName() + " " + teacher.getPhoneNo() + " " + teacher.getEmail() + " " + teacher.getTeacherNo() + " " + teacher.getDepartment() + "<br>" + "\n");
        }
        sb.append("\t\t</blockquote>" + "\n");

        sb.append("\t</body>" + "\n");
        sb.append("</html>");
        return sb.toString();
    }
}
